<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 13966
  Date: 2021/5/24
  Time: 8:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title-give-chenlei</title>
    <link rel="stylesheet" href="bootstrap-3.3.5/dist/css/bootstrap.css">
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        function fenye(cpage) {
            $("[name='cpage']").val(cpage);
            $("form").submit();
        }
        function tui(id) {
            $.ajax({
                url:"tui.do",
                data:{id:id},
                type:"post",
                dataType:"json",
                success:function () {
                    location.href="list.do";
                }
            })
        }
        function del(id) {
            if(confirm("是否删除")){
                $.ajax({
                    url:"del.do",
                    data:{id:id},
                    type:"post",
                    dataType:"json",
                    success:function () {
                        location.href="list.do";
                    }
                })
            }
        }
        function chu(id) {
            $.ajax({
                url:"chu.do",
                data:{id:id},
                type:"post",
                dataType:"json",
                success:function () {
                    location.href="list.do";
                }
            })
        }
        function toadd() {
            location.href="toadd.do";
        }
        function xin(id) {
            location.href="selById.do?id="+id;
        }
    </script>
</head>
<body>
    <form action="/list.do" class="">
        <input readonly="readonly" name="cpage" type="hidden">
        小区名称：<input type="text" name="name" value="${map.name}">
        出租状态：<select name="status">
        <option value="" >请选择</option>
        <option value="1"${map.status==1?'selected':''}>已租</option>
        <option value="2"${map.status==2?'selected':''}>待租</option>
    </select>
        装修情况：<select name="stype">
        <option value="">请选择</option>
        <option value="1"${map.status==1?'selected':''}>精装修</option>
        <option value="2"${map.status==2?'selected':''}>简装</option>
        <option value="3"${map.status==3?'selected':''}>毛坯房</option>
    </select>
        挂牌时间：<input type="date" name="startTime">
        <input type="submit" value="查询">
        <input type="button" value="添加" onclick="toadd()">
    </form>
    <table>
        <t>
            <th>编号</th>
            <th>小区名称</th>
            <th>单元楼</th>
            <th>门牌号</th>
            <th>实景图</th>
            <th>状态</th>
            <th>挂牌时间</th>
            <th>出租时间</th>
            <th>户型</th>
            <th>装修情况</th>
            <th>配套设施</th>
            <th>操作</th>
        </t>
        <c:forEach items="${pi.list}" var="p">
            <tr>
                <td>${p.id}</td>
                <td>${p.name}</td>
                <td>${p.building}</td>
                <td>${p.number}</td>
                <td><img src="${p.picture}" alt="无法显示" width="75px"></td>
                <td>${p.status==1?'已组':'待租'}</td>
                <td>${p.listing_time}</td>
                <td>${p.rental_time}</td>
                <td>${p.tname}</td>
                <td>
                    <c:if test="${p.type==1}">
                        精装修
                    </c:if>
                    <c:if test="${p.type==2}">
                        简装
                    </c:if>
                    <c:if test="${p.type==3}">
                        毛坯房
                    </c:if>
                </td>
                <td>${p.snames}</td>
                <td>
                    <c:if test="${p.status==1}">
                        <input type='button' value='退租' onclick='tui(${p.id})'>
                        <input type='button' value='新增设施' onclick='xin(${p.id})'>
                    </c:if>
                    <c:if test="${p.status==2}">
                        <input type='button' value='删除' onclick='del(${p.id})'>
                        <input type='button' value='出租' onclick='chu(${p.id})'>
                        <input type='button' value='新增设施' onclick='xin(${p.id})'>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="11">
                <input type="button" value="上一页" onclick="fenye(${pi.isFirstPage?1:pi.prePage})">
                <span>${pi.pageNum} / ${pi.pages}</span>
                <input type="button" value="下一页" onclick="fenye(${pi.isLastPage?pi.pages:pi.nextPage})">
            </td>
        </tr>
    </table>
</body>
</html>
